<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
   	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    
    <link href="<%=request.getContextPath()%>/css/bootstrap.css" rel="stylesheet" type="text/css">
    <script src="<%=request.getContextPath()%>/js/jquery-2.0.3.min.js" type="text/javascript"></script>
    <script src="<%=request.getContextPath()%>/js/bootstrap.js" type="text/javascript"></script>  
    
    
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrapValidator.css"/>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/bootstrapValidator.js"></script>
    
    <script src="<%=request.getContextPath()%>/js/jquery.twbsPagination.js" type="text/javascript"></script>   
    
    <script src="<%=request.getContextPath()%>/js/ajaxfileupload.js"></script>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/fileupload.css"/>
    
    <script type="text/javascript">
    $(document).ready(function () {
	    $('#pagination-demo').twbsPagination({	    	
	        totalPages: ${pageCount},
	        visiblePages: ${pageCount}>10?10:${pageCount},
			startPage:${page},
	        version: '1.1',
	        first: "首页",
	        last: "未页",
	        prev: '上一页',
	        next: '下一页',
	        onPageClick: function (event, page) {	        	
	        	if(page!=${page}){
	        		var params="${params}";
	        		if(params!='choose'){
						document.getElementById("defaultForm").action="<%=request.getContextPath()%>/productPic/ProductPic_listByPage.action?page="+ page +"&rows=10";
	        		}
	        		if(params=='choose'){
   					    document.getElementById("defaultForm").action="<%=request.getContextPath()%>/productPic/ProductPic_listByPage.action?params=choose&page="+ page +"&rows=5";
	        		}
        		    document.getElementById("defaultForm").submit();
	        	}	        	
	        }
	    });

    });
    
    function dele(id)
    {
    	var r=confirm("是否删除？");
    	if(r)
   		{	
    		location.href="productPic/ProductPic_delete.action?page="+${page}+"&id="+id;
   		}
    	
    }
    </script>
</head>

<body>
<div class="panel panel-primary">
    <div class="panel-heading">商品图片管理</div>

<c:if test="${params!='choose' }"> 
    <div class="panel-body"> 

		<form class="form-horizontal" id="defaultForm" action="ProductPic_listByPage.action" method="post">
		  	<table>
		  		<tr>
		  			<td><input type="text" name="t1.name" class="form-control" id="name" placeholder="请输入商品图片名称" style="width: 150px"  value="${t1.name}"></td>
		  			<td><button type="submit" class="btn btn-default">查询</button></td>
		  			<td><button type="button" onclick="location.href='<%=request.getContextPath()%>/productPic/ProductPic_toAdd.action'" class="btn btn-default">增加</button></td>
		  		    <td><button type="button" onclick="location.href='<%=request.getContextPath()%>/productPic/ProductPic_downloadTemplet.action'" class="btn btn-default">模板下载</button></td>
		  			<td>
		  				<input id="detailsDocumentUpload" type="file" name="file" onchange="ajaxFileUpload('productPic/ProductPic_uploadExeclData.action')" /> 
     					<input type="button"  class="btn btn-default" value="Excel上传" onclick="javascript:detailsDocumentUpload.click()" />
		  			</td>
		  		</tr>
		  	</table>
		</form>
 
    </div>
  
  
        <table class="table table-bordered table-hover">
            <thead>
			    <tr>
					 <th style="align:center;width:20%">商品图片</th>
					 <th style="align:center;width:10%">图片名称</th>
					 <th style="align:center;width:20%">图片路径</th>
					 <th style="align:center;width:15%">创建时间</th>
					 <th style="align:center;width:10%">创建人</th>
			         <th style="align:center;width:15%">操作</th>
			    </tr>
		    </thead>
		    <s:iterator value="#list">
			    <tr>
					 <th><img src="${path}" height=100px /></th>
					 <th>${name}</th>
					 <th>${path}</th>
					 <th>${creationTime}</th>
					 <th>${creator}</th>
			        <th>
				        <a class="btn btn-primary btn-sm" href="ProductPic_get.action?page=${page}&id=${id }" role="button" >修改</a>
			            <a class="btn btn-primary btn-sm" onclick="dele(${id })" href="#" role="button" >删除</a>
			        </th>
			    </tr>        
		    </s:iterator>
		</table>  
</c:if>



<c:if test="${params=='choose' }">
    <div class="panel-body"> 

		<form class="form-horizontal" id="defaultForm" action="ProductPic_listByPage.action?params=choose&rows=5" method="post">
		  	<table>
		  		<tr>
		  			<td><input type="text" name="t1.name" class="form-control" id="name" placeholder="请输入详情名称" style="width: 150px"  value="${t1.name}"></td>
		  			<td><button type="submit" class="btn btn-default">查询</button></td>
		  		</tr>
		  	</table>
		</form>
 
    </div>
  
  
        <table class="table table-bordered table-hover">
            <thead>
			    <tr>
					 <th>商品图片</th>
					 <th>商品名称</th>
			         <th>操作</th>
			    </tr>
		    </thead>
		    <s:iterator value="#list">
			    <tr>
					 <th><img src="${path }" style="width:150px;height:100px"/></th>
					 <th>${name }</th>
			        <th>
				        <input type="hidden" name="nameChoose" id="${id }" value="${path }"/>
						<input type="radio" name="idChoose" value="${id }"/>
			        </th>
			    </tr>        
		    </s:iterator>
		</table>  
</c:if>  
</div>
		
		<section id="main-content">
		    <p>
		        <div class="text-center" display="inline">
		            <ul id="pagination-demo" class="pagination-sm">&nbsp;&nbsp;&nbsp;共${pageCount}页</ul>
		        </div>
		    </p>
		</section> 

</body>
</html>
